package com.study.salary.utils;

import org.springframework.beans.BeansException;
import org.springframework.context.ApplicationContext;
import org.springframework.context.ApplicationContextAware;

/**
 * @author caoqianhuan
 * @date 2022/8/17
 * @Description:
 */
public class ApplicationUtil implements ApplicationContextAware {
    private static ApplicationContext context;

    public static ApplicationContext getApplicationContext() {
        return context;
    }
    public void setContext (ApplicationContext context) {
        ApplicationUtil.context = context;
    }
    @Override
    public void setApplicationContext(ApplicationContext applicationContext) throws BeansException {
        if (ApplicationUtil.context == null) {
            setContext(applicationContext);
        }
    }
}
